package com.cz.modules.cll.controller;

import java.text.ParseException;
import java.util.Arrays;
import java.util.Map;

import com.cz.common.validator.ValidatorUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.cz.modules.cll.entity.CllMonitoringPointEntity;
import com.cz.modules.cll.service.CllMonitoringPointService;
import com.cz.common.utils.PageUtils;
import com.cz.common.utils.R;



/**
 * 卡口管理
 *
 * @author Cz
 * @email 
 * @date 2020-04-23 14:09:10
 */
@RestController
@RequestMapping("cll/cllmonitoringpoint")
public class CllMonitoringPointController {
    @Autowired
    private CllMonitoringPointService cllMonitoringPointService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("cll:cllmonitoringpoint:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = cllMonitoringPointService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("cll:cllmonitoringpoint:info")
    public R info(@PathVariable("id") String id){
        CllMonitoringPointEntity cllMonitoringPoint = cllMonitoringPointService.getById(id);

        return R.ok().put("cllMonitoringPoint", cllMonitoringPoint);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("cll:cllmonitoringpoint:save")
    public R save(@RequestBody CllMonitoringPointEntity cllMonitoringPoint){
        cllMonitoringPointService.save(cllMonitoringPoint);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("cll:cllmonitoringpoint:update")
    public R update(@RequestBody CllMonitoringPointEntity cllMonitoringPoint){
        ValidatorUtils.validateEntity(cllMonitoringPoint);
        cllMonitoringPointService.updateById(cllMonitoringPoint);
        
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("cll:cllmonitoringpoint:delete")
    public R delete(@RequestBody String[] ids){
        cllMonitoringPointService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

    @RequestMapping("/getPointList")
    @RequiresPermissions("cll:cllmonitoringpoint:save")
    public R getPointList(){
        try {
            cllMonitoringPointService.getPointList();
        }catch (Exception e){
            e.printStackTrace();
        }
        return R.ok();
    }

}
